package com.wenyu.wenyuyuedu.adapter.homepagefragment;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wenyu.wenyuyuedu.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/8.
 */

public class HomeItemImageAdapter extends BaseAdapter {
    private List<String> listImage = new ArrayList<>();
    private Context context;

    public HomeItemImageAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return listImage.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        HomeItemImageHolder holder = null;
        if(view == null){
            holder = new HomeItemImageHolder();
            view = View.inflate(context, R.layout.home_itemimage_adapter, null);
            holder.home_image = (ImageView)view.findViewById(R.id.home_image);
            view.setTag(holder);
        }else {
             holder = (HomeItemImageHolder) view.getTag();
        }
        Glide.with(context)
                .load(listImage.get(i))
                .into(holder.home_image);
        return view;
    }

    class HomeItemImageHolder {
        ImageView home_image;
    }
    public void addAll(List<String> listImage){
        this.listImage = listImage;
        notifyDataSetChanged();

    }
}
